const follower = document.getElementById("follower");
let pos = { x: 100, y: 100 };
const mouse = { x: 0, y: 0 };

document.addEventListener("mousemove", (e) => {
  mouse.x = e.clientX;
  mouse.y = e.clientY;
});
// 直接赋值：
function update() {
  pos.x = mouse.x;
  pos.y = mouse.y;
}
// 线性插值
const smoothness = 0.1;
function update2() {
  pos.x += (mouse.x - pos.x) * smoothness;
  pos.y += (mouse.y - pos.y) * smoothness;
}
// 立方缓动
function update3() {
}
// 动画循环
function animate() {
  //直接赋值：
  //update();
  //线性插值：
  update2();
  follower.style.left = pos.x - 25 + "px";
  follower.style.top = pos.y - 25 + "px";
  requestAnimationFrame(animate);
}
animate();
